<?php
function simplexml_load_file2($URL)
{
	$ch = curl_init($URL);

	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_HEADER, 0);

	$xml = simplexml_load_string(curl_exec($ch));

	curl_close($ch);

	return $xml;
}

if (!isset ($flickr_id) || !isset ($flickr_api_key) || !isset ($flickr_use_curl))
{
	echo 'Please set the <b>$flickr_use_curl</b>, <b>$flickr_id</b> and <b>$flickr_api_key</b> variables before requiring this file. Be careful, only PHP 5 supported!';
}
else
{
	if ($flickr_use_curl)
		$flickr = simplexml_load_file2("http://flickr.com/services/rest/?method=flickr.people.getPublicPhotos&user_id=$flickr_id&api_key=$flickr_api_key");
	else
		$flickr = simplexml_load_file("http://flickr.com/services/rest/?method=flickr.people.getPublicPhotos&user_id=$flickr_id&api_key=$flickr_api_key");

	// echo '<pre>';
	// print_r($flickr);
	// echo '</pre>';

	$count = $flickr->photos['total'];

	for ($i = 0; $i < $count; $i++)
	{
		$photo = $flickr->photos->photo[$i];
		$format = 't';
		$title = $photo['title'];
		$thumb = 'http://static.flickr.com/' . $photo['server'] . '/' . $photo['id'] . '_' . $photo['secret'] . '_' . $format . '.jpg';
		$url = 'http://static.flickr.com/' . $photo['server'] . '/' . $photo['id'] . '_' . $photo['secret'] . '.jpg';
?>
				<div style="padding: 0; margin-right: 8px; margin-bottom: 8px; float: left;">
					<div style="border: 1px solid #999; padding: 8px; margin: 0; text-align: center; width: 128px; height: 128px;">
						<a target="photo" href="<?php echo $url; ?>" title="<?php echo $title; ?>">
							<img style="border: 0;" src="<?php echo $thumb; ?>" alt="<?php echo $title; ?>" /><br />
						</a>
						<?php echo $title; ?>
					</div>
				</div>
			<?php


	}
}
?>
